import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/getToken',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
// 商品列表
export function goodsPage(data) {
  return request({
    url: 'backend/goods/goodsPage',
    method: 'post',
    data
  })
}
// 修改商品
export function updateGoods(data) {
  return request({
    url: 'backend/goods/updateGoods',
    method: 'post',
    data
  })
}
// 删除商品
export function deleteGoods(goodsId) {
  return request({
    url: `/backend/goods/deleteGoods/${goodsId}`,
    method: 'post'
  })
}
// 商品上下架
export function goodsStatusUpdate(data) {
  return request({
    url: '/backend/goods/goodsStatusUpdate',
    method: 'post',
    data
  })
}
// 商品详情
export function goodsDetail(goodsId) {
  return request({
    url: `/backend/goods/goodsDetail/${goodsId}`,
    method: 'post'
  })
}
// 上传图片
export function uploadImg(data) {
  return request({
    url: '/backend/file/image',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
// 上传视频
export function uploadVideo(data) {
  return request({
    url: '/backend/file/video',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
// 添加商品
export function saveProducts(data) {
  return request({
    url: '/backend/goods/saveProducts',
    method: 'post',
    data
  })
}
// 订单
// 订单列表
export function orderRefund(data) {
  return request({
    url: '/backend/order/refund',
    method: 'post',
    data
  })
}
// 订单
export function orderList(data) {
  return request({
    url: '/backend/order/orderList',
    method: 'post',
    data
  })
}
export function saleAmount(data) {
  return request({
    url: '/backend/order/saleAmount',
    method: 'post',
    data
  })
}
// 货柜
// 货柜列表
export function machineList(data) {
  return request({
    url: '/backend/machine/machineList',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}
// 货道
// 新增货道配置 - 货道商品库存不为0的不允许变更
export function saveProductChannelConfig(data) {
  return request({
    url: '/backend/channel/saveProductChannelConfig',
    method: 'post',
    data
  })
}
// 货道配置列表
export function channelConfigs(machineId) {
  return request({
    url: `/backend/channel/channelConfigs/${machineId}`,
    method: 'post'
  })
}
// 支付结果
// 支付结果通知
export function payNotify(data) {
  return request({
    url: '/pay/payNotify',
    method: 'post',
    data
  })
}
// 退款结果通知
export function refundNotify(data) {
  return request({
    url: '/pay/refundNotify',
    method: 'post',
    data
  })
}
// 上传广告素材
export function createAds(data) {
  return request({
    url: '/backend/ads/createAds',
    method: 'post',
    data
  })
}

// 查看广告素材
export function currentAds(data) {
  return request({
    url: '/backend/ads/currentAds',
    method: 'post',
    data
  })
}

// 优惠券管理
// 优惠券列表
export function couponList(data) {
  return request({
    url: 'backend/coupon/couponList',
    method: 'post',
    data
  })
}
// 新增优惠券
export function addCoupon(data) {
  return request({
    url: 'backend/coupon/createCoupon',
    method: 'post',
    data
  })
}
// 优惠券上下架
export function couponStatusUpdate(data) {
  return request({
    url: '/backend/coupon/couponStatusUpdate',
    method: 'post',
    data
  })
}

// 销售数量
export function orderStatistics(data) {
  return request({
    url: 'backend/order/orderStatistics',
    method: 'post',
    data
  })
}